ass Solution {
public:
    string compressString(string S) {
        string ret;
        char prev=S[0];
        size_t cur=1;
        size_t sum=1;
        while(cur<=S.size())
        {
            if(S[cur]==prev)
            {
                sum++;
            }
            else
            {
                ret+=prev;
                ret+=to_string(sum);
                sum=1;
                prev=S[cur];
            }
            cur++;
        }
        if(ret.size()>=S.size())
        return S;

        return ret;
    }
};


class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        vector<int> ret;
        ret.resize(2,-1);
        int left=0;
        int right=numbers.size()-1;
        while(left<right)
        {
            if(numbers[left]+numbers[right]==target)
            {
                ret[0]=left;
                ret[1]=right;
                break;
            }
            else if(numbers[left]+numbers[right]>target)
            {
                right--;//bian xiao
            }
            else
            {
                left++;//bian da
            }
        }
        return ret;
    }
};

class Solution {
public:
    int MoreThanHalfNum_Solution(vector<int> numbers) {
        map<int,int> mp;
        for(auto e:numbers)
        {
            mp[e]++;
        }
        for(auto e:mp)
        {
            if(e.second>numbers.size()/2)
            {
                return e.first;
            }
        }
        return -1;
    }
};

